class Car {
  constructor(make, model, year) {
    this.make = make
    this.model = model
    this.year = year
  }
  speak() {
    console.log(`${this.year} ${this.make} ${this.model}`)
  }
}

class Beetle extends Car {
  constructor(make, model, year) {
    // super 用于访问和调用一个对象的父对象上的函数
    // 传递给 super 的参数会被传递给父类的构造函数
    super(make, model, year)
    // super() 只能在使用 this 之前调用
    this.wheels = 4
  }
  speak() {
    super.speak()
    console.log(`I have ${this.wheels} wheels`)
  }
}

let myBeetle = new Beetle('volkswagen', 'beetle', 1967)

myBeetle.speak()
// console.log(myBeetle)
